﻿package com.cat.service.common.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.DetachedCriteria;

import com.cat.bean.FlowProcessVo;
import com.cat.bean.common.PageBean;
import com.cat.bean.common.Pager;
import com.cat.dao.common.BaseDao;
import com.cat.service.common.BaseService;

public class BaseServiceImpl<T, PK extends Serializable> implements BaseService<T, PK> {

	private BaseDao<T, PK> baseDao;

	public BaseDao<T, PK> getBaseDao() {
		return baseDao;
	}
	
	public void setBaseDao(BaseDao<T, PK> baseDao) {
		this.baseDao = baseDao;
	}

	public T get(PK id) {
		return baseDao.get(id);
	}

	public T load(PK id) {
		return baseDao.load(id);
	}
	
	public List<T> get(PK[] ids) {
		return baseDao.get(ids);
	}
	
	public T get(String propertyName, Object value) {
		return baseDao.get(propertyName, value);
	}
	
	public List<T> getList(String propertyName, Object value) {
		return baseDao.getList(propertyName, value);
	}

	public List<T> getAll() {
		return baseDao.getAll();
	}
	
	public Long getTotalCount() {
		return baseDao.getTotalCount();
	}

	public boolean isUnique(String propertyName, Object oldValue, Object newValue) {
		return baseDao.isUnique(propertyName, oldValue, newValue);
	}
	
	public boolean isExist(String propertyName, Object value) {
		return baseDao.isExist(propertyName, value);
	}

	public PK save(T entity) {
		return baseDao.save(entity);
	}

	public void update(T entity) {
		baseDao.update(entity);
	}

	public void delete(T entity) {
		baseDao.delete(entity);
	}

	public void delete(PK id) {
		baseDao.delete(id);
	}

	public void delete(PK[] ids) {
		baseDao.delete(ids);
	}
	
	public void flush() {
		baseDao.flush();
	}

	public void clear() {
		baseDao.clear();
	}
	
	public void evict(Object object) {
		baseDao.evict(object);
	}

	public Pager findByPager(Pager pager) {
		return baseDao.findByPager(pager);
	}
	
	public Pager findByPager(Pager pager, DetachedCriteria detachedCriteria) {
		return baseDao.findByPager(pager, detachedCriteria);
	}
	
	public int getTotalCount(String hql, Map map) {
		return baseDao.getTotalCount(hql, map);
	}
	
	public int getTotalCount(String sql) {
		return baseDao.getTotalCount(sql);
	}
	
	public List<T> findPageByQuery(String hql, Map map, PageBean pageBean) {
		return baseDao.findPageByQuery(hql, map, pageBean);
	}
	
	public List<Object[]> findPageByQuery(String hql, PageBean pageBean) {
		return baseDao.findPageByQuery(hql, pageBean);
	}
	
	public List<Object[]> getDraftWorkflowPageBySql(String sql, PageBean pageBean) {
		return baseDao.getDraftWorkflowPageBySql(sql, pageBean);
	}
	
	public List<Object[]> getWorkflowPageBySql(String sql, PageBean pageBean) {
		return baseDao.getWorkflowPageBySql(sql, pageBean);
	}
	
	/**
	 * 根据编码删除流程
	 * 
	 * @param workflowId
	 */
	public void deleteWorkflowRecord(String workflowId) {
		baseDao.deleteWorkflowRecord(workflowId);
	}
	
	/**
	 * 根据SQL语句更新数据
	 * 
	 * @param sql
	 */
	public void updateBySql(String sql) {
		baseDao.updateBySql(sql);
	}

	@Override
  public List<FlowProcessVo> getFlowProcessByTaskId(Integer taskId) {
	  return baseDao.getFlowProcessByTaskId(taskId);
  }

}

